package com.project.slsx.adapter;

import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.project.slsx.R;
import com.project.slsx.bean.CategoryBean;

import java.util.ArrayList;

public class PurchCategoryAdapter extends BaseQuickAdapter<CategoryBean.ResultBean, BaseViewHolder> {
    private ArrayList<Boolean> selectedIndex = new ArrayList<>();

    public ArrayList<Boolean> getSelectedIndex() {
        return selectedIndex;
    }

    public void setSelectedIndex(ArrayList<Boolean> selectedIndex) {
        this.selectedIndex = selectedIndex;
    }

    public PurchCategoryAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(BaseViewHolder holder, CategoryBean.ResultBean item) {
        holder.setText(R.id.tv_cash_title, item.getTitle());
        View bg = holder.getView(R.id.item_bg);
        bg.setSelected(selectedIndex.get(holder.getLayoutPosition()));
    }

    public void setItemSelected(ArrayList<Boolean> categorySelected) {
        this.selectedIndex = categorySelected;
        notifyDataSetChanged();
    }
}
